package main

import (
	"fmt"
	"reflect"
)

func main() {
	test1 := func(v1, v2 int) {
		fmt.Printf("%d + %d = %d\n", v1, v2, v1+v2)
	}
	test2 := func(v1, v2 int, s string) {
		fmt.Printf("[%s] %d + %d = %d\n", s, v1, v2, v1+v2)
	}
	Adapter(test1, 1, 2)
	Adapter(test2, 1, 2, "3")
}

func Adapter(caller interface{}, args ...interface{}) {
	var rVal = reflect.ValueOf(caller)
	var argsLen = len(args)
	var valueArgs []reflect.Value
	for i := 0; i < argsLen; i++ {
		valueArgs = append(valueArgs, reflect.ValueOf(args[i]))
	}
	rVal.Call(valueArgs)
}
